<%@ Page Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeBehind="Helpdesk.aspx.cs" Inherits="MusicmanWeb.USER.Helpdesk" Title="Musicman Levi9 | Feedback" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server">
<script type="text/javascript" language="JavaScript">
    function ToggleEdit(id)
    {
        var itemObj = document.getElementById('item_' + id);
        var editObj = document.getElementById('edit_' + id);
        if (itemObj != null && editObj != null)
        {
            itemObj.style.display = "none";
            editObj.style.display = "block";
        }
    }    
</script>

    <div class="page" id="home">
    <div id="sidebar">
        <asp:GridView 
            ID="GridView1" 
            runat="server" 
            DataSourceID="ObjectDataSource1" 
            AllowPaging="True"
            PageSize="10"
            AutoGenerateColumns="false" 
            Width="200px">
        <Columns>
        <asp:TemplateField>
        <HeaderTemplate>
        Date
        </HeaderTemplate>
        <ItemTemplate>
        <asp:LinkButton 
            ID="Search" 
            runat="server" 
            CausesValidation="False" 
            CommandName="Search" 
            OnCommand="Search_Command"
            CommandArgument='<%# String.Format("{0}-{1}-{2}", Eval("Year"), Eval("Month"), Eval("Day")) %>'>
            <%# Eval("Day") %>-<%# Eval("Month") %>-<%# Eval("Year") %>
        </asp:LinkButton>
        </ItemTemplate>
        </asp:TemplateField>
        </Columns>
        </asp:GridView>
    
    </div>
        
    <div id="content">
    	<h3>Help Musicman to develop</h3>
	    <p>You can participate in Musicman Levi9 improvement by posting you feedback</p>
	    <hr	/>
        <asp:GridView ID="GridView2" 
            runat="server" 
            DataSourceID="ObjectDataSource2" 
            AutoGenerateColumns="False"
            Width="400px" OnRowDataBound="GridView2_RowDataBound"
            DataKeyNames="ID"
            >
        <Columns>
        <asp:TemplateField HeaderText="Feedback">
        <ItemTemplate>
            <asp:HiddenField ID="userid" runat="server" Value='<%# Bind("PersonID") %>' />
            From <%# Eval("From") %>
            <br />
            Subject <%# Eval("Subject") %>
            <br />
            Date <%# Eval("Date.Day") %>-<%# Eval("Date.Month") %>-<%# Eval("Date.Year") %>
            <br />
            <hr />
            <%# Eval("Feedback") %>
            <hr />
            </ItemTemplate>
            <EditItemTemplate>
               From <%# Eval("From") %>
               <br />
               <asp:TextBox ID="SubjectTxt" runat="server" Width="400" Text='<%# Bind("Subject") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="SubjectTxt"
                    ErrorMessage="RequiredFieldValidator" ValidationGroup="Editing">*</asp:RequiredFieldValidator>&nbsp;
               <br />
               Date <%# Eval("Date.Day") %>-<%# Eval("Date.Month") %>-<%# Eval("Date.Year") %>
               <br />
               <asp:TextBox ID="FeedbackTxt" runat="server" TextMode="MultiLine" Width="400" Rows="7" Text='<%# Bind("Feedback") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="FeedbackTxt"
                    ErrorMessage="RequiredFieldValidator" ValidationGroup="Editing">*</asp:RequiredFieldValidator>&nbsp;
               <asp:HiddenField ID="ID" runat="server" Value='<%# Bind("ID") %>' />
                &nbsp;&nbsp;
               <asp:HiddenField ID="userid" runat="server" Value='<%# Bind("PersonID") %>' />
            </EditItemTemplate>

        </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Update" ValidationGroup="Editing"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="Edit" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Edit"></asp:LinkButton>
                    <asp:LinkButton ID="Delete" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="Delete"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        </asp:GridView>
        <asp:GridView ID="GridView3" 
            runat="server" 
            DataSourceID="ObjectDataSource3" 
            AutoGenerateColumns="False"
            Width="400px" OnRowDataBound="GridView2_RowDataBound"
            DataKeyNames="ID"
            Visible="false" OnRowUpdated="GridView3_RowUpdated">
        <Columns>
        <asp:TemplateField HeaderText="Feedback">
        <ItemTemplate>
            <asp:HiddenField ID="userid" runat="server" Value='<%# Bind("PersonID") %>' />
            From <%# Eval("From") %>
            <br />
            Subject <%# Eval("Subject") %>
            <br />
            Date <%# Eval("Date.Day") %>-<%# Eval("Date.Month") %>-<%# Eval("Date.Year") %>
            <br />
            <hr />
            <%# Eval("Feedback") %>
            <hr />
            </ItemTemplate>
            <EditItemTemplate>
               From <%# Eval("From") %>
               <br />
               <asp:TextBox ID="SubjectTxt" runat="server" Width="400" Text='<%# Bind("Subject") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="SubjectTxt"
                    ErrorMessage="RequiredFieldValidator" ValidationGroup="Editing">*</asp:RequiredFieldValidator>
               <br />
               Date <%# Eval("Date.Day") %>-<%# Eval("Date.Month") %>-<%# Eval("Date.Year") %>
               <br />
               <asp:TextBox ID="FeedbackTxt" runat="server" TextMode="MultiLine" Width="400" Rows="7" Text='<%# Bind("Feedback") %>'></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="FeedbackTxt"
                    ErrorMessage="RequiredFieldValidator" ValidationGroup="Editing">*</asp:RequiredFieldValidator>
               <asp:HiddenField ID="ID" runat="server" Value='<%# Bind("ID") %>' />
                &nbsp;&nbsp;
               <asp:HiddenField ID="userid" runat="server" Value='<%# Bind("PersonID") %>' />
            </EditItemTemplate>

        </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Update" ValidationGroup="Editing"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="Edit" runat="server" CausesValidation="False" CommandName="Edit"
                        Text="Edit"></asp:LinkButton>
                    <asp:LinkButton ID="Delete" runat="server" CausesValidation="False" CommandName="Delete"
                        Text="Delete"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        </asp:GridView>
            <hr />
        	   <asp:Label ID="Label1" runat="server" Text="Label">Subject</asp:Label>
	    <br />
        <asp:TextBox ID="Subject" runat="server" Width="395px"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Subject"
            ErrorMessage="RequiredFieldValidator" ValidationGroup="Adding">*</asp:RequiredFieldValidator><br />
        <asp:Label ID="Label2" runat="server" Text="Label">Feed back</asp:Label>
        <br />
        <asp:TextBox ID="Feedback" runat="server" Height="84px" Rows="10" TextMode="MultiLine"
            Width="395px"></asp:TextBox>
        &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Feedback"
            ErrorMessage="RequiredFieldValidator" ValidationGroup="Adding">*</asp:RequiredFieldValidator><br />
            <asp:LinkButton ID="LinkButton1" runat="server" OnCommand="LinkButton1_Command" ValidationGroup="Adding">Add</asp:LinkButton>&nbsp;
        </div>

   </div>
    

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="LoadUserFeedBackDates" TypeName="Musicman.Business.DataManager" EnableCaching="False"></asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                          TypeName="Musicman.Business.DataManager" 
                          EnableCaching="False"
                          SelectMethod="LoadLatestFeedback"
                          UpdateMethod="SaveUserFeedback"
                          DeleteMethod="DeleteUserFeedback">
        <SelectParameters>
            <asp:Parameter Name="top" Direction="Input" Type="int32" DefaultValue="5" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource3" runat="server" 
                          TypeName="Musicman.Business.DataManager" 
                          EnableCaching="False"
                          SelectMethod="LoadFeedBackPerDay"
                          UpdateMethod="SaveUserFeedback"
                          DeleteMethod="DeleteUserFeedback">
        <SelectParameters>
            <asp:Parameter Name="day" Direction="Input" Type="string"/>
        </SelectParameters>
    </asp:ObjectDataSource>
   
</asp:Content>
